<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title th:replace="common/base::pagetitle"></title>
    <link th:replace="common/base::static"/>
    <link rel="stylesheet" th:href="@{/static/plugins/easyui/themes/material/easyui.css}">
    <link rel="stylesheet" th:href="@{/static/plugins/easyui/themes/icon.css}">
    <link rel="stylesheet" th:href="@{/static/css/wlb-treegrid.css}">
</head>
<body style="background-color: #f2f2f2;">

<div id="credit">


    <div id="kPage" class="layui-fluid" style="padding: 0">
        <div class="layui-row">
            <!-- 主要内容块 -->
            <div class="layui-col-md12" id="kMainContentCol">
                <div class="layui-fluid wlb-fluid-padding15">
                    <div class="layui-card">
                        <form>
                            <div class="layui-form layui-card-header wlb-card-header-auto">

                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">使用时间</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input" name="useDate" id="useDate"
                                                   placeholder="请选择使用时间">
                                        </div>
                                    </div>

                                    <div class="layui-inline">
                                        <label class="layui-form-label">额度使用区间</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="applyAmountStart" placeholder="请输入起始额度" autocomplete="off"
                                                   class="layui-input">
                                        </div>
                                        <div class="layui-input-inline">
                                            <input type="text" name="applyAmountEnd" placeholder="请输入结束额度" autocomplete="off"
                                                   class="layui-input">
                                        </div>
                                    </div>

                                    <div class="layui-inline">
                                        <button class="layui-btn " lay-submit="" lay-filter="kTableSearchFilter">
                                            <i class="layui-icon layui-icon-search"></i>
                                        </button>
                                        <button class="layui-btn " type="reset">
                                            <i class="layui-icon layui-icon-refresh-1"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </form>

                        <div class="layui-card-body">
                            <table id="kContentTable" lay-filter="kContentTable"></table>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<script th:replace="common/base::context"></script>
<script th:replace="common/base::mainjs"></script>
<script th:src="@{/static/plugins/easyui/easyloader.js}"></script>

<script type="text/html" id="typeTpl">
    {{# if(d.type === '0') { }}
    <span class="layui-badge layui-bg-green">融资扣款</span>
    {{#  } else if(d.type === '1') { }}
    <span class="layui-badge layui-bg-orange">还款恢复</span>
    {{# } }}
</script>


<script type="text/javascript" th:inline="javascript">

    var active;
    layui.use(['element', 'form', 'layer', 'table', 'laytpl','laydate'], function () {
        var elemet = layui.element, form = layui.form, layer = layui.layer, table = layui.table,laydate = layui.laydate;
        var tableId = 'kContentTable';

        // 实例化table
        var tableIns = table.render($.extend(config.layui.table, {
            elem: '#' + tableId
            , url: api.credit.creditUseListData //数据接口
            , response: {dataName: 'records', countName: 'total'}
            , toolbar: '#headToolbarTpl'
            , cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                , {field: 'useDate', title: '使用时间', width: 200, fixed: false}
                , {field: 'amount', title: '使用额度', width: 180, fixed: false}
                , {field: 'type', title: '类型', width: 80, templet: '#typeTpl', fixed: false}
                , {field: 'beforAmount', title: '使用前额度', width: 180, fixed: false}
                , {field: 'afterAmount', title: '使用后额度', width: 180,}
                , {field: 'remark', title: '摘要', width: 180,}
            ]]
        }));
        var area = ['450px', '530px'];


        // 监听事件
        active = {
            user_info: function (that) {
                var supplierId = $(that).data('supplierid');
                // var auditId = $(that).data('id');
                // 1详情 2审核
                var type = 1;
                var status = $(that).data('status');
                var index = layer.open({
                    type: 2
                    ,
                    title: '详情'
                    ,
                    content: api.credit.creditAuditView + "?supplierId=" + supplierId + "&type=" + type + "&status=" + status
                    ,
                    maxmin: true
                    ,
                    area: area   // 宽高
                });
                // layer.full(index);

            },

        };

        wlbKit.activeInit(active);

        $(window).resize(function () {
            treeGridKit.fitRightFrozenCol(tableId);
        });

        // 列格式化函数
        var formatter = {
            typeTpl: function (value, row, index) {
                return wlbKit.renderTpl('typeTpl', row);
            },
        };

        // 监听查询
        form.on('submit(kTableSearchFilter)', function (obj) {
            var params = obj.field;
            log('seach=', params); //

            tableIns.reload({
                where: params,
                page: {curr: 1}
            });
            return false;

        });

        // 绑定监听回车事件
        wlbKit.bindEnterEventForLayuiForm();

        // 开始日期
        laydate.render({
            elem: '#useDate' //指定元素
        });

    });
</script>

</body>
</html>
